package cpr.command;

import cpr.DefaultCommandHandler;
import cpr.Printer;
import cpr.context.SolveContext;
import cpr.data.SolveBestRulesEntry;

public class CmdSolutionLoad extends DefaultCommandHandler {
	public CmdSolutionLoad() {
		super("sol-load","loads solution", null,null);
	}
	public void execute(String[] params) throws Exception {
		int wsId = getParameterInteger(params, 1,-1);
		SolveContext sctx = null;
		if (wsId==-1) {
			sctx = getCommandContext().getContext().assertCurrentSolveContext();

		} else {
			sctx = getCommandContext().getContext().getCurrentWorksetContext().createSolveContext(wsId);
			getCommandContext().getContext().setCurrentSolveContext(sctx);
		}
		SolveBestRulesEntry sbre = sctx.loadSolution(false);
		if (sbre==null) {
			Printer.println("Failed");
		} else {
			sctx.printSolution();
		}
	}
}
